# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models
from django.utils import timezone
# Create your models here.


class Classifies(models.Model):
    classname = models.CharField('类别名',max_length=50)
    classkey = models.CharField('类别索引',max_length=100)
    clickcount = models.IntegerField('点击数',default=0)
    weight = models.IntegerField('权重',default=0)
    def __unicode__(self):
        return self.classname


class Movie(models.Model):
    moviename = models.CharField('电影名', max_length=100)
    prefilename = models.CharField('视频文件前缀名', max_length=50, blank=True)
    suffixname = models.CharField('视频文件后缀名', max_length=20, default=".mp4" ,blank=True)
    createtime = models.DateTimeField('发表时间', auto_now_add=True)
    updatetime = models.DateTimeField('更改时间', auto_now=True)
    publishtime = models.CharField('发布时间', max_length=50, blank=True)
    types = models.CharField('类型', max_length=200, blank=True)
    area = models.CharField('地区', max_length=200, blank=True)
    language = models.CharField('语言', max_length=200, blank=True)
    actor = models.CharField('主演', max_length=200, blank=True)
    director = models.CharField('导演', max_length=200, blank=True)
    keyword = models.CharField('索引键值', max_length=200, blank=True)
    weight = models.IntegerField('权重', default=0)
    countnumber = models.IntegerField('总集数', default=0)
    avaliblesum = models.IntegerField('当前更新集数', default=0)
    introduce = models.CharField('简介', max_length=2000, blank=True)
    clickcount = models.IntegerField('点击数', default=0)
    playcount = models.IntegerField('播放量', default=0)
    duration = models.CharField('总时长', max_length=100, blank=True)
    isoutsource = models.CharField('是否外链视频', max_length=2, default='0')
    picurl = models.CharField('封面链接', max_length=500, default='http://p5ppxhuor.bkt.clouddn.com/default.jpg')
    classify = models.ForeignKey(Classifies, verbose_name="类别", null=True, on_delete=models.CASCADE)
    def __unicode__(self):
        return self.moviename


class Outsource(models.Model):
    num = models.IntegerField('第几集', default=1)
    outfilelink = models.CharField('外部文件链接', max_length=500)
    movie = models.ForeignKey(Movie, verbose_name="电影", on_delete=models.CASCADE)
    def __unicode__(self):
        return str(self.num)


class Log(models.Model):
    righttime = models.CharField('当前时间',max_length=50)
    url =  models.CharField('链接',max_length=100, null=True)
    params = models.CharField('参数', max_length=100, null=True)
    ip = models.CharField('IP', max_length=100, null=True)
    method=models.CharField('method',max_length=100, null=True)
    def __unicode__(self):
        return self.ip